/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.renren.common.constant.CommonConstant;
import io.renren.modules.category.entity.*;
import io.renren.modules.category.service.TBrandService;
import io.renren.modules.category.service.TCategoryService;
import io.renren.modules.category.service.TConsumerService;
import io.renren.modules.category.service.TInitialService;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.*;
import java.util.stream.Collectors;



/**
 * 不区分 男士女士
 * 执行顺序
 * 1.把业务王冉提供的品牌Excel 导入到
 * 2.运行 ExcelTest818.java.testImportExcel()
 * 目的是把 excel数据导入到 t_brand 表中
 * 3.运行CategoryTest818.java.buildJson() 生成的 json
 * 4.第三步的json 放到ducc开关中
 *
 * 测试：
 * 运行CategoryTest818.testParseJson
 * brandCategoryJson 值为第三步生成的json
 *
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class CategoryTest818 {
    @Autowired
    private TConsumerService consumerService;
    @Autowired
    private TBrandService brandService;
    @Autowired
    private TInitialService initialService;
    @Autowired
    private TCategoryService categoryService;


    /**
     * 构建品牌分类 JSON
     */
    @Test
    public void buildJson(){
        String brandJson = buildBrandJson();
        System.out.println("============================");
        System.out.println(brandJson);
    }


    /**
     * 解析Json 数据
     * 入参：
     * consumerId:101
     * collection: 1:只看收藏
     */
    @Test
    public void testParseJson(){
        Boolean collection=true;
        //模拟ducc配置的品牌数据
        String brandCategoryJson="{\"consumerlList\":[{\"id\":101,\"name\":\"女士\",\"sort\":1,\"initialList\":null},{\"id\":102,\"name\":\"男士\",\"sort\":2,\"initialList\":null}],\"initialList\":[{\"name\":\"热门品牌\",\"brandList\":[{\"id\":1001,\"name\":\"louis vuitton\",\"shopId\":\"10935451\"},{\"id\":1002,\"name\":\"gucci\",\"shopId\":\"12774182\"},{\"id\":1003,\"name\":\"coach自营\",\"shopId\":\"1000002971\"},{\"id\":1004,\"name\":\"burberry\",\"shopId\":\"1000002973\"},{\"id\":1005,\"name\":\"prada\",\"shopId\":\"12451106\"}]},{\"name\":\"A\",\"brandList\":[{\"id\":1006,\"name\":\"a-cold-wall*\",\"shopId\":\"12554756\"},{\"id\":1007,\"name\":\"acne studios\",\"shopId\":\"1000346845\"},{\"id\":1008,\"name\":\"alberta ferretti\",\"shopId\":\"1000099913\"},{\"id\":1009,\"name\":\"alexander mcqueen\",\"shopId\":\"1000327630\"},{\"id\":1010,\"name\":\"alexandre de paris\",\"shopId\":\"68978\"},{\"id\":1011,\"name\":\"ami paris\",\"shopId\":\"11473454\"},{\"id\":1012,\"name\":\"anteprima\",\"shopId\":\"10030704\"},{\"id\":1013,\"name\":\"apede mod\",\"shopId\":\"10432876\"},{\"id\":1014,\"name\":\"arte\",\"shopId\":\"874624\"},{\"id\":1015,\"name\":\"axel arigato\",\"shopId\":\"1000337207\"}]},{\"name\":\"B\",\"brandList\":[{\"id\":1016,\"name\":\"bally自营\",\"shopId\":\"1000009302\"},{\"id\":1017,\"name\":\"bally官旗\",\"shopId\":\"10819171\"},{\"id\":1018,\"name\":\"baccarat\",\"shopId\":\"871998\"},{\"id\":1019,\"name\":\"be@rbrick\",\"shopId\":\"1000377800\"},{\"id\":1020,\"name\":\"berluti\",\"shopId\":\"11127455\"},{\"id\":1021,\"name\":\"bohemia\",\"shopId\":\"10318869\"},{\"id\":1022,\"name\":\"bonpoint\",\"shopId\":\"10214775\"},{\"id\":1023,\"name\":\"boss\",\"shopId\":\"802648\"},{\"id\":1024,\"name\":\"both\",\"shopId\":\"1000388179\"},{\"id\":1025,\"name\":\"bottega veneta\",\"shopId\":\"12605712\"},{\"id\":1026,\"name\":\"brooksbrothers\",\"shopId\":\"10064497\"},{\"id\":1027,\"name\":\"buben & zorweg\",\"shopId\":\"10818611\"},{\"id\":1028,\"name\":\"burberry\",\"shopId\":\"1000002973\"},{\"id\":1029,\"name\":\"bvlgari\",\"shopId\":\"11444736\"}]},{\"name\":\"C\",\"brandList\":[{\"id\":1030,\"name\":\"c'n'c\",\"shopId\":\"707856\"},{\"id\":1031,\"name\":\"calvinluo\",\"shopId\":\"12320857\"},{\"id\":1032,\"name\":\"camille fournet\",\"shopId\":\"969997\"},{\"id\":1033,\"name\":\"canada goose\",\"shopId\":\"11504591\"},{\"id\":1034,\"name\":\"canali\",\"shopId\":\"12351458\"},{\"id\":1035,\"name\":\"capalex paris\",\"shopId\":\"11125090\"},{\"id\":1036,\"name\":\"Carl F.Bucherer\",\"shopId\":\"1000102722\"},{\"id\":1037,\"name\":\"cartier \",\"shopId\":\"1000002730\"},{\"id\":1038,\"name\":\"cerruti 1881\",\"shopId\":\"837200\"},{\"id\":1039,\"name\":\"celine\",\"shopId\":\"11810231\"},{\"id\":1040,\"name\":\"chloe\",\"shopId\":\"1000148761\"},{\"id\":1041,\"name\":\"chopard自营\",\"shopId\":\"1000014842\"},{\"id\":1042,\"name\":\"chopard官旗\",\"shopId\":\"11442619\"},{\"id\":1043,\"name\":\"christofle\",\"shopId\":\"12397239\"},{\"id\":1044,\"name\":\"church's\",\"shopId\":\"1000330041\"},{\"id\":1045,\"name\":\"coach自营\",\"shopId\":\"1000002971\"},{\"id\":1046,\"name\":\"coach官旗\",\"shopId\":\"10280114\"},{\"id\":1047,\"name\":\"corum\",\"shopId\":\"10265263\"},{\"id\":1048,\"name\":\"cosmic speculation\",\"shopId\":\"1000365081\"},{\"id\":1049,\"name\":\"culti\",\"shopId\":\"12790656\"}]},{\"name\":\"D\",\"brandList\":[{\"id\":1050,\"name\":\"dare one\",\"shopId\":\"699473\"},{\"id\":1051,\"name\":\"david naman\",\"shopId\":\"12127623\"},{\"id\":1052,\"name\":\"davidoff\",\"shopId\":\"10102565\"},{\"id\":1053,\"name\":\"de beers\",\"shopId\":\"12520484\"},{\"id\":1054,\"name\":\"delvaux\",\"shopId\":\"10157982\"},{\"id\":1055,\"name\":\"desigual\",\"shopId\":\"12761932\"},{\"id\":1056,\"name\":\"dior\",\"shopId\":\"11593735\"},{\"id\":1057,\"name\":\"dkny\",\"shopId\":\"907370\"}]},{\"name\":\"E\",\"brandList\":[{\"id\":1058,\"name\":\"etro\",\"shopId\":\"878940\"},{\"id\":1059,\"name\":\"etudes studio\",\"shopId\":\"1000369021\"},{\"id\":1060,\"name\":\"emporio armani自营\",\"shopId\":\"1000077045\"},{\"id\":1061,\"name\":\"emporio armani官旗\",\"shopId\":\"11591059\"}]},{\"name\":\"F\",\"brandList\":[{\"id\":1062,\"name\":\"fabrique\",\"shopId\":\"12406139\"},{\"id\":1063,\"name\":\"fendi\",\"shopId\":\"12038891\"},{\"id\":1064,\"name\":\"ferragamo\",\"shopId\":\"1000002772\"},{\"id\":1065,\"name\":\"ferre\",\"shopId\":\"879250\"},{\"id\":1066,\"name\":\"fred\",\"shopId\":\"12871115\"},{\"id\":1067,\"name\":\"furla自营\",\"shopId\":\"1000012903\"},{\"id\":1068,\"name\":\"furla官旗\",\"shopId\":\"832522\"}]},{\"name\":\"G\",\"brandList\":[{\"id\":1069,\"name\":\"   galtiscopio\",\"shopId\":\"10158626\"},{\"id\":1070,\"name\":\"gas bijoux\",\"shopId\":\"10255927\"},{\"id\":1071,\"name\":\"gentle monster\",\"shopId\":\"11445842\"},{\"id\":1072,\"name\":\"georg jensen\",\"shopId\":\"11519858\"},{\"id\":1073,\"name\":\"giuseppe zanotti\",\"shopId\":\"839516\"},{\"id\":1074,\"name\":\"gieves & hawkes\",\"shopId\":\"871897\"},{\"id\":1075,\"name\":\"givenchy\",\"shopId\":\"11624131\"},{\"id\":1076,\"name\":\"golden goose\",\"shopId\":\"11261202\"},{\"id\":1077,\"name\":\"goossens\",\"shopId\":\"1000313562\"},{\"id\":1078,\"name\":\"gucci\",\"shopId\":\"12774182\"},{\"id\":1079,\"name\":\"guidi\",\"shopId\":\"1000387085\"}]},{\"name\":\"H\",\"brandList\":[{\"id\":1080,\"name\":\"hogan\",\"shopId\":\"717821\"}]},{\"name\":\"I\",\"brandList\":[{\"id\":1081,\"name\":\"issey miyake\",\"shopId\":\"1000178171\"}]},{\"name\":\"J\",\"brandList\":[{\"id\":1082,\"name\":\"jimmy choo\",\"shopId\":\"1000155621\"},{\"id\":1083,\"name\":\"john lobb\",\"shopId\":\"10441201\"},{\"id\":1084,\"name\":\"justine clenquet jewellery\",\"shopId\":\"1000372922\"},{\"id\":1085,\"name\":\"juun.j\",\"shopId\":\"1000341102\"},{\"id\":1086,\"name\":\"jw anderson\",\"shopId\":\"1000351864\"}]},{\"name\":\"K\",\"brandList\":[{\"id\":1087,\"name\":\"kate spade\",\"shopId\":\"1000002867\"},{\"id\":1088,\"name\":\"k&irene\",\"shopId\":\"11510641\"},{\"id\":1089,\"name\":\"kent&curwen\",\"shopId\":\"604864\"},{\"id\":1090,\"name\":\"kenzo\",\"shopId\":\"1000013485\"},{\"id\":1091,\"name\":\"korloff\",\"shopId\":\"1000383762\"}]},{\"name\":\"L\",\"brandList\":[{\"id\":1092,\"name\":\"lancel\",\"shopId\":\"1000164284\"},{\"id\":1093,\"name\":\"la perla\",\"shopId\":\"649425\"},{\"id\":1094,\"name\":\"lanvin\",\"shopId\":\"11634958\"},{\"id\":1095,\"name\":\"lauren ralph lauren\",\"shopId\":\"682634\"},{\"id\":1096,\"name\":\"les nereides\",\"shopId\":\"11495808\"},{\"id\":1097,\"name\":\"loewe\",\"shopId\":\"11574099\"},{\"id\":1098,\"name\":\"longchamp\",\"shopId\":\"1000003147\"},{\"id\":1099,\"name\":\"louis vuitton\",\"shopId\":\"10935451\"}]},{\"name\":\"M\",\"brandList\":[{\"id\":1100,\"name\":\"mackage\",\"shopId\":\"12187286\"},{\"id\":1101,\"name\":\"maison kitsune\",\"shopId\":\"12016745\"},{\"id\":1102,\"name\":\"maison margiela\",\"shopId\":\"11897508\"},{\"id\":1103,\"name\":\"mangano\",\"shopId\":\"10070248\"},{\"id\":1104,\"name\":\"manito\",\"shopId\":\"819676\"},{\"id\":1105,\"name\":\"manu atelier\",\"shopId\":\"1000339905\"},{\"id\":1106,\"name\":\"marc jacobs\",\"shopId\":\"1000148509\"},{\"id\":1107,\"name\":\"marimekko\",\"shopId\":\"12468611\"},{\"id\":1108,\"name\":\"marni\",\"shopId\":\"1000354721\"},{\"id\":1109,\"name\":\"maxmara自营\",\"shopId\":\"1000282341\"},{\"id\":1110,\"name\":\"maxmara官旗\",\"shopId\":\"12131564\"},{\"id\":1111,\"name\":\"mcm自营\",\"shopId\":\"1000004762\"},{\"id\":1112,\"name\":\"mcm官旗\",\"shopId\":\"11771362\"},{\"id\":1113,\"name\":\"michael kors自营\",\"shopId\":\"1000002369\"},{\"id\":1114,\"name\":\"michael kors官旗\",\"shopId\":\"12036857\"},{\"id\":1115,\"name\":\"missoni\",\"shopId\":\"12730559\"},{\"id\":1116,\"name\":\"miu miu\",\"shopId\":\"12459555\"},{\"id\":1117,\"name\":\"moncler\",\"shopId\":\"1000119641\"},{\"id\":1118,\"name\":\"moneta\",\"shopId\":\"1000375408\"},{\"id\":1119,\"name\":\"montblanc\",\"shopId\":\"1000002681\"},{\"id\":1120,\"name\":\"moose knuckles\",\"shopId\":\"11859824\"},{\"id\":1121,\"name\":\"moschino自营\",\"shopId\":\"1000166103\"},{\"id\":1122,\"name\":\"moschino官旗\",\"shopId\":\"12055994\"},{\"id\":1123,\"name\":\"msgm\",\"shopId\":\"1000313543\"},{\"id\":1124,\"name\":\"mulberry\",\"shopId\":\"10027536\"}]},{\"name\":\"N\",\"brandList\":[{\"id\":1125,\"name\":\"neil barrett\",\"shopId\":\"1000387090\"}]},{\"name\":\"O\",\"brandList\":[{\"id\":1126,\"name\":\"omega\",\"shopId\":\"1000002795\"},{\"id\":1127,\"name\":\"orrdt\",\"shopId\":\"10134402\"}]},{\"name\":\"P\",\"brandList\":[{\"id\":1128,\"name\":\"palace skateboards\",\"shopId\":\"1000396751\"},{\"id\":1129,\"name\":\"paul smith\",\"shopId\":\"1000148905\"},{\"id\":1130,\"name\":\"philipp plein\",\"shopId\":\"12367361\"},{\"id\":1131,\"name\":\"philippe ferrandis\",\"shopId\":\"10257399\"},{\"id\":1132,\"name\":\"pinko\",\"shopId\":\"1000092131\"},{\"id\":1133,\"name\":\"polina\",\"shopId\":\"10346878\"},{\"id\":1134,\"name\":\"prada\",\"shopId\":\"12451106\"}]},{\"name\":\"Q\",\"brandList\":[{\"id\":1135,\"name\":\"qeelin\",\"shopId\":\"1000384641\"},{\"id\":1136,\"name\":\"qeelin\",\"shopId\":\"13011250\"},{\"id\":1137,\"name\":\"queen anne\",\"shopId\":\"10322810\"}]},{\"name\":\"R\",\"brandList\":[{\"id\":1138,\"name\":\"ralph lauren\",\"shopId\":\"682634\"},{\"id\":1139,\"name\":\"rare\",\"shopId\":\"11713382\"},{\"id\":1140,\"name\":\"riedel\",\"shopId\":\"11446038\"},{\"id\":1141,\"name\":\"rimowa\",\"shopId\":\"10290443\"},{\"id\":1142,\"name\":\"rogervivier\",\"shopId\":\"11613320\"},{\"id\":1143,\"name\":\"ruggeroguidi\",\"shopId\":\"1000387085\"}]},{\"name\":\"S\",\"brandList\":[{\"id\":1144,\"name\":\"s.t.dupont\",\"shopId\":\"208173\"},{\"id\":1145,\"name\":\"seletti\",\"shopId\":\"1000340881\"},{\"id\":1146,\"name\":\"senreve\",\"shopId\":\"10537162\"},{\"id\":1147,\"name\":\"sergio rossi\",\"shopId\":\"1000331021\"},{\"id\":1148,\"name\":\"shang xia\",\"shopId\":\"10053672\"},{\"id\":1149,\"name\":\"sheme\",\"shopId\":\"10475053\"},{\"id\":1150,\"name\":\"shine li\",\"shopId\":\"10725892\"},{\"id\":1151,\"name\":\"silky miracle\",\"shopId\":\"907243\"},{\"id\":1152,\"name\":\"stefano ricci\",\"shopId\":\"10311292\"},{\"id\":1153,\"name\":\"steiff\",\"shopId\":\"1000409221\"},{\"id\":1154,\"name\":\"stone island\",\"shopId\":\"1000324204\"},{\"id\":1155,\"name\":\"stuart weitzman\",\"shopId\":\"1000093683\"}]},{\"name\":\"T\",\"brandList\":[{\"id\":1156,\"name\":\"TAG Heuer\",\"shopId\":\"10273523\"},{\"id\":1157,\"name\":\"the bridge\",\"shopId\":\"12202209\"},{\"id\":1158,\"name\":\"tiffany\",\"shopId\":\"12346986\"},{\"id\":1159,\"name\":\"tod's\",\"shopId\":\"155240\"},{\"id\":1160,\"name\":\"tom dixon\",\"shopId\":\"1000334344\"},{\"id\":1161,\"name\":\"tory burch自营\",\"shopId\":\"1000003110\"},{\"id\":1162,\"name\":\"tory burch官旗\",\"shopId\":\"11611316\"},{\"id\":1163,\"name\":\"tumi\",\"shopId\":\"1000120902\"}]},{\"name\":\"V\",\"brandList\":[{\"id\":1164,\"name\":\"valentino自营\",\"shopId\":\"1000009245\"},{\"id\":1165,\"name\":\"valentino官旗\",\"shopId\":\"12351551\"},{\"id\":1166,\"name\":\"veja\",\"shopId\":\"1000313583\"},{\"id\":1167,\"name\":\"versace\",\"shopId\":\"1000006641\"},{\"id\":1168,\"name\":\"versace jeans couture\",\"shopId\":\"1000282943\"},{\"id\":1169,\"name\":\"vitaring\",\"shopId\":\"12451362\"}]},{\"name\":\"W\",\"brandList\":[{\"id\":1170,\"name\":\"white mountaineering\",\"shopId\":\"1000349381\"},{\"id\":1171,\"name\":\"wooyoungmi\",\"shopId\":\"1000346845\"},{\"id\":1172,\"name\":\"yohji yamamoto\",\"shopId\":\"1000346845\"},{\"id\":1173,\"name\":\"yuzefi\",\"shopId\":\"1000346845\"}]},{\"name\":\"Z\",\"brandList\":[{\"id\":1174,\"name\":\"zadig&voltaire\",\"shopId\":\"12305477\"},{\"id\":1175,\"name\":\"ZEGNA\",\"shopId\":\"1000014528\"},{\"id\":1176,\"name\":\"ZENITH自营\",\"shopId\":\"1000002825\"},{\"id\":1177,\"name\":\"ZENITH官旗\",\"shopId\":\"12239761\"}]}]}";
        //测试收藏的品牌
        List<FollowResultPO> followResultList = new ArrayList<>();
        FollowResultPO followResultPO = new FollowResultPO();
        FollowResultPO followResultPO2 = new FollowResultPO();
        FollowResultPO followResultPO3 = new FollowResultPO();
        followResultPO.setBizId("1006");
        followResultPO2.setBizId("1009");
        followResultPO3.setBizId("1273");
        followResultList.add(followResultPO);
        followResultList.add(followResultPO2);
        followResultList.add(followResultPO3);
        BrandCategoryPO brandCategoryPO = parseJson(collection, brandCategoryJson, followResultList);
        ObjectMapper mapper = new ObjectMapper();
        try {
            String json = mapper.writeValueAsString(brandCategoryPO);
            System.out.println("===========");
            System.out.println(json);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }


    /**
     * 不区分男士女士
     * @return
     */
    public String buildBrandJson(){
        Map<String, Object> consumerParams = new HashMap<>();
        Map<String, Object> brandParams;
        List<TConsumerEntity> consumerList = consumerService.selectList(consumerParams);
        List<TInitialEntity> initialListNew  = new ArrayList<>();
        List<String> alphabetList = Arrays.asList(CommonConstant.alphabetArr);
        for (String alphabet : alphabetList) {
            brandParams = new HashMap<>();
            brandParams.put("initialCode",alphabet);
            List<TBrandEntity> brandEntities = brandService.selectListByCode(brandParams);
            if(CollectionUtils.isEmpty(brandEntities)){
                continue;
            }
            TInitialEntity initialEntity = new TInitialEntity();
            initialEntity.setName(alphabet.contains("热") ? CommonConstant.HOT_BRAND :alphabet);
            initialEntity.setBrandList(brandEntities);
            initialListNew.add(initialEntity);
        }
        ConsumerInitialPO consumerInitialPO = new ConsumerInitialPO();
        consumerInitialPO.setConsumerlList(consumerList);
        consumerInitialPO.setInitialList(initialListNew);
        ObjectMapper mapper = new ObjectMapper();
        String json="";
        try {
            json = mapper.writeValueAsString(consumerInitialPO);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        return json;
    }

    /**
     * 解析 json
     */
    public BrandCategoryPO parseJson(Boolean collection,String brandJson, List<FollowResultPO> followResultList){
        Set<String> collectSet = getCollectionSet(followResultList);
        ConsumerInitialVO consumer = JSON.parseObject(brandJson, ConsumerInitialVO.class);
        //收藏的集合
        List<InitialPO> initialCollectionList;
        //全部 集合 包括收藏与非收藏
        List<InitialPO> initialPOList = new ArrayList<>();
        List<InitialPO> initialPOListResp = new ArrayList<>();
        List<BrandPO> brandCollectionVOList = null;
        InitialPO initialCollectionVO =null;
            initialCollectionList = new ArrayList<>();
            List<InitialPO> initials = consumer.getInitialList();
            for(InitialPO initial : initials){
                //只看收藏的时候，不返回热门品牌分类
                if(collection && initial.getName().contains(CommonConstant.HOT_BRAND)){
                    continue;
                }
                //遍历，收藏标识 赋值
                brandCollectionVOList = new ArrayList<>();
                for(BrandPO brandPO:initial.getBrandList()){
                    boolean isCollection =collectSet.contains(String.valueOf(brandPO.getId()));
                    brandPO.setCollection(isCollection);
                    if(collection && isCollection){
                        brandCollectionVOList.add(brandPO);
                    }
                }
                if(collection && CollectionUtils.isNotEmpty(brandCollectionVOList)){
                    initialCollectionVO = new InitialPO();
                    initialCollectionVO.setName(initial.getName());
                    initialCollectionVO.setBrandList(brandCollectionVOList);
                    initialCollectionVO.setSort(initial.getSort());
                    initialCollectionList.add(initialCollectionVO);
                }else{
                    initialPOList.add(initial);
                }
            }
            if(collection){
                //收藏的 数据
                initialPOListResp.addAll(initialCollectionList);
            }else{
                //全部 数据
                initialPOListResp.addAll(initialPOList);
            }
        BrandCategoryPO brandCategoryPO = new BrandCategoryPO();
        brandCategoryPO.setBrands(initialPOListResp);
        return brandCategoryPO;
    }

    /**
     *收藏的集合转换为 set
     */
    private Set<String> getCollectionSet(List<FollowResultPO> followResultList){
        if(CollectionUtils.isEmpty(followResultList)){
            return new HashSet<>();
        }
        // 将 List<BrandPO> 中的 name 属性转换为 Set<String>
        Set<String> collectionSet = followResultList.stream().map(FollowResultPO::getBizId).collect(Collectors.toSet());
        return collectionSet;
    }





    /**
     * 构建Json 全部品牌和 商品品类
     */
    public String buildCategoryJson(){
        List<TCategoryEntity> categoryList = categoryService.selectList(new HashMap<>());
        ObjectMapper mapper = new ObjectMapper();
        String json="";
        try {
            json = mapper.writeValueAsString(categoryList);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        return json;
    }


    @Test
    public void buildJson4(){
        String[] alphabets = new String[26]; // 创建长度为 26 的字符串数组
        for (int i = 0; i < 26; i++) {
            alphabets[i] = String.valueOf((char) ('A' + i)); // 将字符转换为字符串
        }
        for (String aChar : alphabets) {
            System.out.print("\""+aChar+"\""+",");
        }
    }
    @Test
    public void buildJson6(){
        Map<String, Object> params = new HashMap<>();
        params.put("k","val");
        System.out.println(JSON.toJSONString(params));
    }





}
